#include<stdio.h>
int main()
{
    int t,n,m,i,j,k,flag;
    char x[10005];
    char y[10005];
    scanf("%d",&t);getchar();
    while(t--)
    {
    	scanf("%d%d",&n,&m);getchar();
        flag=1;
        gets(y);
        gets(x);
        if(x[0]='0'&&y[0]=='1')
            flag=0;
        if(x[m-1]=='0'&&y[0]=='0')
            flag=0;
        if(x[0]=='1'&&y[n-1]=='1')
            flag=0;
        if(x[m-1]=='1'&&y[n-1]=='0')
            flag=0;
        if(flag)
            printf("Happy\n");
        else
            printf("Sad\n");
    }
    return 0;
}
